<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   如何高效地将SQL数据映射到NoSQL存储系统中  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/6900.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459294: Accept with keywords: (title(0.2):数据,存储系统,地将,数盟,社区, topn(0.266666666667):社区,数盟,行业资讯,编译器,数据挖掘,目录,集群,架构,示例,Python,数据库,职业规划,基础架构,文章,格式,数据,存储系统,元组,主键,客户端,语句,事务管理,功能,方式,部分,代码,系统,应用程序,容错性,内容).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    如何高效地将SQL数据映射到NoSQL存储系统中
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    如何高效地将SQL数据映射到NoSQL存储系统中 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,71] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/base">
       基础架构
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/6900.html">
          如何高效地将SQL数据映射到NoSQL存储系统中
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,363 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/base" rel="category tag">
          基础架构
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        作者
        <a class="editorlink f_taxonomyEditor" href="http://www.infoq.com/cn/author/Sytze-Harkema">
         Sytze Harkema
        </a>
        ，译者
        <strong>
         <a class="editorlink f_taxonomyTranslator" href="http://www.infoq.com/cn/author/%E9%82%B5%E6%80%9D%E5%8D%8E">
          邵思华
         </a>
        </strong>
       </p>
       <p>
        通常来说，我们都知道：
       </p>
       <ul>
        <li>
         SQL数据库只限在单机上运行，但它提供了更强的事务管理、schema与查询功能。
        </li>
        <li>
         NoSQL数据库为了伸缩性与容错性的目的，放弃了事务管理与schema。
        </li>
       </ul>
       <p>
        而FoundationDB的SQL层结合了这两个方面：它首先是一个开源的SQL数据库，能够线性地伸缩与提升容错性，并且还具有真正的ACID事务功能。曾经互不相容的两种特性，现在已融合在一个统一的系统中。
       </p>
       <p>
        对于处于以下几种情况的公司来说，这一特性是非常重要的：
       </p>
       <ul>
        <li>
         新的项目要为大规模的伸缩性进行计划。
        </li>
        <li>
         现有的项目遇到了数据库伸缩性的瓶颈。
        </li>
        <li>
         现有的许多项目希望能用一个唯一的、容错性强的数据库抽象层统一工作模式。
        </li>
       </ul>
       <p>
        在本文中，我将为读者介绍
        <a href="https://foundationdb.com/">
         FoundationDB
        </a>
        ，并解释
        <a href="https://foundationdb.com/layers/sql">
         FoundationDB的SQL层
        </a>
        是怎样将SQL数据映射到
        <a href="https://foundationdb.com/key-value-store">
         FoundationDB中的键-值存储
        </a>
        后台系统中的。
       </p>
       <h2>
        NoSQL数据库 ——FoundationDB的键-值存储系统
       </h2>
       <p>
        FoundationDB是一个分布式的键-值存储系统，支持全局ACID事务操作，并且性能出众。在安装系统时，可以指定
        <a href="https://foundationdb.com/key-value-store/documentation/configuration.html#choosing-a-redundancy-mode">
         数据分发的级别
        </a>
        。数据分发为容错性提供了支持：当某个服务器或网络的某部分产生故障时，数据库仍然可以正常操作，你的应用也不会受到影响。
       </p>
       <h2>
        键-值与SQL架构
       </h2>
       <p>
        我们开发的这套架构能够在键-值存储系统上支持多个层，每个层都能够在FoundationDB的基础上提供一套不同的数据模型，例如SQL数据库、文档数据库或图形数据库。许多使用者也自行创建了自定义的层。
       </p>
       <div id="lowerFullwidthVCR">
       </div>
       <p>
        下图中列出架构中的了关键部分。处于最底层的是FoundationDB集群，无论集群的实际大小如何，对它的操作与一个单独的逻辑数据库并没有分别。SQL层则以一种无状态的中间层方式运行在键-值存储系统之上。这一层通过SQL与应用程序进行通信，并使用FoundationDB的客户端API与键-值存储系统进行通信。由于SQL层是无状态的，因此可以并行地运行任意数据的SQL层。
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/01/1218030.png"/>
       </p>
       <h2>
        SQL层为键-值存储系统带来了如Google的F1般的能力
       </h2>
       <p>
        SQL层是对SQL与键-值存储API进行转换的一套逻辑严密的层。首先，SQL层会从一条SQL语句开始，将其转换为最高效地键-值操作。这种方式类似于编译器将代码转换为低级别的执行格式。并且，这种转换是完全符合ANSI SQL 92标准的。开发者可以将该功能与ORM、REST API进行接合，或者直接使用SQL层的命令行界面进行调用。从代码的角度来说，SQL层与键-值存储是完全分离的，它是通过FoundationDB的Java绑定方式与键-值存储进行通信的。感兴趣的读者可以查看
        <a href="https://github.com/FoundationDB/sql-layer">
         FoundationDB的SQL层在GitHub上的代码库
        </a>
        ，其代码是完全开源的。眼下唯一能够和这套系统进行比较的是
        <a href="http://static.googleusercontent.com/media/research.google.com/en/us/pubs/archive/41344.pdf">
         Google的F1
        </a>
        ，后者是一套基于该公司的Spanner技术所创建的SQL引擎。
       </p>
       <p>
        如以下的简单图例所示，SQL层是由一系列组件所组成的。应用程序通过某种受支持的SQL客户端向SQL层发送查询语句，在解析之后转换为一棵计划节点树。优化器（Optimizer）会计算最佳的执行计划，并以一棵操作符树的方式表现出来，随后由执行框架（Execution Framework）运行。在执行阶段，对数据的请求将被发送到存储虚拟（Storage Abstraction）层，这一层通过使用Java的键-值API在数据与FoundationDB集群之间进行传输。数据库模型将存放在Information Schema层中，这一层将被其它多个组件所调用。
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/01/1218031.png"/>
       </p>
       <h2>
        将SQL数据映射到键-值存储系统
       </h2>
       <p>
        SQL层需要管理两种类型的数据，首先是信息Schema的元数据，它负责描述所创建的表与可用的索引。其次，它还需要存储实际的数据，包括表内容、索引及序列。我们首先来描述一下这些数据是如何保存在键-值存储系统中的。
       </p>
       <p>
        本质上讲，每个键都是对应了某张表中的特定行的指针，而值则包含了该行的数据。键的分配是由Table-Group所决定的，它是包含了一个或多个表的组。稍后会对这个概念的细节进行更深入的讲解。SQL层会通过使用键-值存储目录层为每个Table-Group创建一个目录，存储目录层是为用户管理键空间的一个工具，它为每个独立的目录分配一个简短的字节数组，作为该目录的唯一键。同时，它也维护着其它元数据，以实现通过名称进行查找的功能。
       </p>
       <p>
        下面这个例子演示了如何创建目录的映射，通过以下语句分配键。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81c1554887806" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE TABLE schema_a.table1(id INT PRIMARY KEY, c CHAR(10));
CREATE TABLE schema_a.table2(id INT PRIMARY KEY);
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81c1554887806-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81c1554887806-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81c1554887806-1">
               <span class="crayon-e">
                CREATE
               </span>
               <span class="crayon-e">
                TABLE
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table1
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                id
               </span>
               <span class="crayon-t">
                INT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                PRIMARY
               </span>
               <span class="crayon-v">
                KEY
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                c
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                CHAR
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81c1554887806-2">
               <span class="crayon-e">
                CREATE
               </span>
               <span class="crayon-e">
                TABLE
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table2
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                id
               </span>
               <span class="crayon-t">
                INT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                PRIMARY
               </span>
               <span class="crayon-v">
                KEY
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0015 seconds] -->
       <p>
        在键-值存储系统中有一些预定义的目录：
       </p>
       <table border="1" cellpadding="0" cellspacing="0">
        <tbody>
         <tr>
          <td valign="top" width="401">
           <p align="center">
            <b>
             Directory
            </b>
           </p>
          </td>
          <td valign="top" width="91">
           <p align="center">
            <b>
             Tuple
            </b>
           </p>
          </td>
          <td valign="top" width="133">
           <p align="center">
            <b>
             Raw Key
            </b>
           </p>
          </td>
         </tr>
         <tr>
          <td valign="top" width="401">
           sql/
          </td>
          <td valign="top" width="91">
           (9)
          </td>
          <td valign="top" width="133">
           \x15\x09
          </td>
         </tr>
         <tr>
          <td valign="top" width="401">
           sql/data/
          </td>
          <td valign="top" width="91">
           (3)
          </td>
          <td valign="top" width="133">
           \x15\x03
          </td>
         </tr>
         <tr>
          <td valign="top" width="401">
           sql/data/table/
          </td>
          <td valign="top" width="91">
           (31)
          </td>
          <td valign="top" width="133">
           \x15\x1F
          </td>
         </tr>
         <tr>
          <td valign="top" width="401">
           sql/data/table/schema_a/table1/
          </td>
          <td valign="top" width="91">
           (215)
          </td>
          <td valign="top" width="133">
           \x15\xD7
          </td>
         </tr>
         <tr>
          <td valign="top" width="401">
           sql/data/table/schema_a/table2/
          </td>
          <td valign="top" width="91">
           (247)
          </td>
          <td valign="top" width="133">
           \x15\xF7
          </td>
         </tr>
        </tbody>
       </table>
       <p>
        在存储数据时，可以选择使用以下三种格式中的一种：“元组（Tuple）”、“原始数据（Row_Data）”或者是“Protobuf”。如果使用默认的Tuple存储格式，那么每一行内容都将保存为一个单独的键-值对，键是通过连接以下字符串所生成的元组：目录前缀、该表在Table-Group中的位置，以及主键。而值的内容则是由该行中的所有列所组成的一个元组。
       </p>
       <p>
        举例来说，以下代码对之前创建的表进行操作，产生对应的键与值。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81d2799318653" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          INSERT INTO schema_a.table1 VALUES (1, 'hello'), (2, 'world');
INSERT INTO schema_a.table2 VALUES (5);
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81d2799318653-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81d2799318653-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81d2799318653-1">
               <span class="crayon-e">
                INSERT
               </span>
               <span class="crayon-e">
                INTO
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table1
               </span>
               <span class="crayon-e">
                VALUES
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'hello'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'world'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81d2799318653-2">
               <span class="crayon-e">
                INSERT
               </span>
               <span class="crayon-e">
                INTO
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table2
               </span>
               <span class="crayon-e">
                VALUES
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0097 seconds] -->
       <p>
       </p>
       <table border="1" cellpadding="0" cellspacing="0">
        <tbody>
         <tr>
          <td valign="top" width="224">
           <p align="center">
            <b>
             Raw Key
            </b>
           </p>
          </td>
          <td valign="top" width="95">
           <b>
            Tuple Key
           </b>
          </td>
          <td valign="top" width="197">
           <p align="center">
            <b>
             Raw Value
            </b>
           </p>
          </td>
          <td valign="top" width="109">
           <b>
            Tuple Value
           </b>
          </td>
         </tr>
         <tr>
          <td valign="top" width="224">
           \x15\xD7\x15\x01\x15\x01
          </td>
          <td valign="top" width="95">
           (215, 1, 1)
          </td>
          <td valign="top" width="197">
           \x15\x01\x02hello\x00
          </td>
          <td valign="top" width="109">
           (1, ‘hello’)
          </td>
         </tr>
         <tr>
          <td valign="top" width="224">
           \x15\xD7\x15\x01\x15\x02
          </td>
          <td valign="top" width="95">
           (215, 1, 2)
          </td>
          <td valign="top" width="197">
           \x15\x02\x02world\x00
          </td>
          <td valign="top" width="109">
           (2, ‘world’)
          </td>
         </tr>
         <tr>
          <td valign="top" width="224">
           \x15\xF7\x15\x01\x15\x05
          </td>
          <td valign="top" width="95">
           (247, 1, 5)
          </td>
          <td valign="top" width="197">
           \x15\x05
          </td>
          <td valign="top" width="109">
           (5)
          </td>
         </tr>
        </tbody>
       </table>
       <p>
        了解了键-值存储系统中键的结构之后，你就能够从存储系统中直接读取数据了。我们将使用FoundationDB的Python API来演示这一功能。在SQL层中，键与值是通过“.pack()”方法进行编码，并通过“.unpack()”方法进行解码的。下面的示例为你演示如何获取并解码数据。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81da044943328" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          import fdb  fdb.api_version(200) 
db = fdb.open() 
directory = fdb.directory.open(db,('sql','data','table','schema_a','table1'))
for key, value in db[directory.range()]:         print fdb.tuple.unpack(key), ' --&amp;gt; ', fdb.tuple.unpack(value)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81da044943328-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81da044943328-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686491e81da044943328-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81da044943328-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81da044943328-1">
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-i">
                fdb
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                api_version
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                200
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81da044943328-2">
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                open
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686491e81da044943328-3">
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                open
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                'sql'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'data'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'table'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'schema_a'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'table1'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81da044943328-4">
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                value
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ' --&amp;gt; '
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                value
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0033 seconds] -->
       <p>
        以上代码会输出类似下面的结果：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81e1606145223" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          (215, 1, 1) --&amp;gt; (1, u'hello') 

(215, 1, 2) --&amp;gt; (2, u'world')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81e1606145223-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81e1606145223-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686491e81e1606145223-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81e1606145223-1">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'hello'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81e1606145223-2">
              </div>
              <div class="crayon-line" id="crayon-57686491e81e1606145223-3">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'world'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0099 seconds] -->
       <p>
        现在让我们再来近距离观察一下Table-Group。每个独立的表都属于一个单独的组，如果某张额外的表能够创建一个对第一张表的“组外键”引用，那么它也能够加入到同一个组中。当我们为某张表创建组外键时，字表将与父表所在的目录进行交互。字表将成为Table-Group的一部分，在源表之后进行命名。这两张表的数据在将同一个目录中进行交互，这保证了范围扫描的高速，并且在Table-Group之内访问对象及表连接的开销极小。为了演示这一特性，我们将继续之前的示例，这一次的SQL语句如下：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81e7154614899" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE TABLE schema_a.table3(id INT PRIMARY KEY, id_1 INT, GROUPING FOREIGN KEY (id_1) REFERENCES schema_a.table1(id));
INSERT INTO schema_a.table3 VALUES (100, 2), (200, 2), (300, 1);
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81e7154614899-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81e7154614899-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81e7154614899-1">
               <span class="crayon-e">
                CREATE
               </span>
               <span class="crayon-e">
                TABLE
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table3
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                id
               </span>
               <span class="crayon-t">
                INT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                PRIMARY
               </span>
               <span class="crayon-v">
                KEY
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                id_1
               </span>
               <span class="crayon-t">
                INT
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                GROUPING
               </span>
               <span class="crayon-e">
                FOREIGN
               </span>
               <span class="crayon-e">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id_1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                REFERENCES
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table1
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81e7154614899-2">
               <span class="crayon-e">
                INSERT
               </span>
               <span class="crayon-e">
                INTO
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table3
               </span>
               <span class="crayon-e">
                VALUES
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                200
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                300
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0027 seconds] -->
       <p>
        该语句将返回以下结果：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81ed481717350" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          directory = fdb.directory.open(db,('sql','data','table','schema_a','table1'))
for key, value in db[directory.range()]:     print fdb.tuple.unpack(key), ' --&amp;gt; ', fdb.tuple.unpack(value)
(215, 1, 1)          --&amp;gt;  (1, u'hello')
(215, 1, 1, 2, 300)  --&amp;gt;  (300, 1) 
(215, 1, 2)          --&amp;gt;  (2, u'world')
(215, 1, 2, 2, 100)  --&amp;gt;  (100, 2)
(215, 1, 2, 2, 200)  --&amp;gt;  (200, 2)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81ed481717350-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81ed481717350-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686491e81ed481717350-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81ed481717350-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686491e81ed481717350-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81ed481717350-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686491e81ed481717350-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81ed481717350-1">
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                open
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                'sql'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'data'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'table'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'schema_a'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                'table1'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81ed481717350-2">
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                value
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ' --&amp;gt; '
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                value
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686491e81ed481717350-3">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'hello'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81ed481717350-4">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                300
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                300
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686491e81ed481717350-5">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'world'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81ed481717350-6">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686491e81ed481717350-7">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                215
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                200
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                200
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0319 seconds] -->
       <p>
        由于第三张表的键都处于第一张表中各行的命名空间范围内，因此第三张表中所有插入的行都能够与第一张表的行相关联。键中的两个额外的值分别对应了Table-Group中的位置以及第三张表中的主键。对表1与表3通过引用键进行连接也无需通过标准的连接操作实现，直接通过线性扫描就语句了。这种排序方式比起传统的关系型数据库系统有着极大的优势。
       </p>
       <p>
        由于键都已经经过排序，因此索引可以直接利用这一点所带来的便利性。所有的表索引只包含一个键值，其中包括两部分内容。每个索引都创建于该表所属的目录之下，一个名为index的子目录中，这是该键元组的第一部分内容。第二个部分是一个组合，首先是该索引所对应的各个列的值，之后则是指定这一行所必须的列的值。
       </p>
       <p>
        举例来说，我们可以为这张表的c列创建一个索引。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81f4099874031" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE INDEX index_on_c ON schema_a.table1(c) STORAGE_FORMAT tuple;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81f4099874031-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81f4099874031-1">
               <span class="crayon-e">
                CREATE
               </span>
               <span class="crayon-e">
                INDEX
               </span>
               <span class="crayon-e">
                index_on_c
               </span>
               <span class="crayon-e">
                ON
               </span>
               <span class="crayon-v">
                schema_a
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table1
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                c
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                STORAGE_FORMAT
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0010 seconds] -->
       <p>
        接下来使用Python读取这个索引的内容，我们需要在Python解释器中加入以下内容：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e81fa029497638" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          directory = fdb.directory.open(db, ('sql', 'data', 'table', 'schema_a', 'table1', 'index_on_c'))
for key, value in db[directory.range()]:     print fdb.tuple.unpack(key), ' --&amp;gt; ', fdb.tuple.unpack(value)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e81fa029497638-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e81fa029497638-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e81fa029497638-1">
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                open
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                'sql'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'data'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'table'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'schema_a'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'table1'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'index_on_c'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e81fa029497638-2">
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                value
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                db
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                directory
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                key
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ' --&amp;gt; '
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fdb
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                unpack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                value
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0120 seconds] -->
       <p>
        这段代码会输入类似于下图中的内容，显示了键的两个组成部分：即该索引所在的目录的字节值，以及创建索引的c列的值加上主键的值。最后一个部分将被索引的值链接到某个特定的行，而该索引键所对应的值为空。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686491e8200583369448" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          (20127, u'hello', 1) --&amp;gt; ()
(20127, u'world', 2) --&amp;gt; ()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686491e8200583369448-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686491e8200583369448-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686491e8200583369448-1">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                20127
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'hello'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686491e8200583369448-2">
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                20127
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                u
               </span>
               <span class="crayon-s">
                'world'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0017 seconds] -->
       <p>
        如果要对SQL层的行为进行更多的控制调整，可以使用以下三种存储格式：一是之前描述过的元组格式，一是列键格式，以及protobuf格式。列健格式会为某一行的每个列值创建一个独立的键-值对。而protobuf存储格式为会每一行创建一个protobuf消息。
       </p>
       <p>
        接下来还需要对元数据进行存储与组织。SQL层使用protobuf消息与基于SQL的数据的结构进行通信。这个结构是由schema、组、表、列、索引与外键等对象共同组成的。
       </p>
       <h2>
        SQL与NoSQL的混合模式
       </h2>
       <p>
        如果在应用程序级别使用只读的键-值API，那么SQL层就能够在客户端进行直接访问。可以通过键-值API直接访问数据，但如果增加或改写了SQL层所用的关键数据，那就很可能破坏系统的运行。这里例举一些可能会产生的问题：缺乏对索引的维护、缺乏应有的限定，以及忽略了对数据及元数据的版本维护。而这种方式的好处，哪怕是在进行数据读取时也并不明显，因为SQL层本身的额外开销就非常小。因此总的来说，性能的开销主要取决于网络延迟。
       </p>
       <h2>
        结论
       </h2>
       <p>
        SQL与NoSQL的结合使用能够相互利用两者的优点。FoundationDB的键-值存储系统为SQL层带来的好处包括可伸缩性、容错性及全局ACID的事务属性。你的应用程序同样也能从中受益，因此赶紧尝试一下吧！对应那些要执行大量的小批数据读取及写入的应用程序来说，FoundationDB提供了一个高伸缩并且安全的解决方案，并且可以任意使用SQL或NoSQL。
       </p>
       <h2>
        关于作者
       </h2>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/01/1218032.jpg"/>
        <b>
         Sytze Harkema
        </b>
        从2014年3月起担任
        <a href="http://foundationdb.com/">
         FoundationDB
        </a>
        的软件工程师，他专注于SQL层的开发，致力于使其成为高伸缩SQL应用的最佳解决方案。Sytzey曾经就读于荷兰的Delft科技大学及美国的哈佛大学。
       </p>
       <div>
       </div>
       <p>
        <strong>
         查看英文原文：
        </strong>
        <a href="http://www.infoq.com/articles/map-sql-nosql">
         How to Effectively Map SQL Data to a NoSQL Store
        </a>
       </p>
       <p>
       </p>
       <p>
        文章出处：infoq
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20037.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t01cbbd7ae2c54cab40.png"/>
        </a>
        <a class="link" href="http://dataunion.org/20037.html" rel="bookmark" title="记一次苦逼的SQL查询优化">
         记一次苦逼的SQL查询优化
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/19122.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/06/t01c8e61852c2874d06-300x225.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/19122.html" rel="bookmark" title="淘宝数据库OceanBase SQL编译器源码阅读：生成逻辑计划">
         淘宝数据库OceanBase SQL编译器源码阅读：生成逻辑计划
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/17652.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/05/QQ截图20150530222020.png"/>
        </a>
        <a class="link" href="http://dataunion.org/17652.html" rel="bookmark" title="QueryBuilder ： 打造优雅的Linq To SQL动态查询">
         QueryBuilder ： 打造优雅的Linq To SQL动态查询
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/17978.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/05/t018837ed7aceeaac4f_副本-300x188.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/17978.html" rel="bookmark" title="视觉中国的NoSQL之路：从MySQL到MongoDB">
         视觉中国的NoSQL之路：从MySQL到MongoDB
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F6900.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/6900.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/6900.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>